<?php
namespace app\admin\controller;

use app\admin\controller\Common;
use think\Db;
use PHPExcel_IOFactory;
use think\facade\Env;
use PHPQRCode\QRcode;

class Map extends Common
{
    public $think;
    public $canvas;

    public function __construct()
    {
        parent::__construct();
        $this->think = $_SESSION['think'];
    }

    /*
       *编辑信息
      */
    public function area()
    {
        $act = input('route.act') ? input('route.act') : 'edit';
        $info = db('area')->where('id=1')->find();
        $date = $info['updated_at'];
        $this->assign('act', $act);
        $this->assign('info', $info);
        $this->assign('date', $date);// 赋值数据集
        return view();
    }
    /*
       *活动处理
      */
    public function areaHandle()
    {
        $data = input('post.');
        $act = $data['act'];
        $data['updated_at'] = date('Y-m-d H:i:s', time());
        unset($data['act']);
        if ($act == 'edit') {
            $id = $data['id'];
            unset($data['id']);
            try {
                $r = db('area')->where('id=' . $id)->update($data);
            } catch (ValidateException $e) {
                // 这是进行验证异常捕获
                return json($e->getError());
            } catch (\Exception $e) {
                // 这是进行异常捕获
                return json($e->getMessage());
            }
            // dump($article_id);exit;
            if ($r !== false) {
                $json['status'] = 1;
                $json['message'] = lang('success');
                /*********************记录日志***********************/
                addLog(session('user_name') . '修改活动成功-' . $data['title'] . ' [ ID:' . $data['article_id'] . ' ]');
                echo json_encode($json);
                exit;
            } else {
                $json['status'] = 0;
                $json['message'] = lang('fail');
                echo json_encode($json);
                exit;
            }

        }

    }

}


?>
